<!DOCTYPE html>
<!-- /* -->
<!--  * Copyright 2016-2021 the original author.All rights reserved. -->
<!--  * AiTeaSoft.com-->
<!--  * Kingstar(aiteasoft@163.com) -->
<!--  * The license,see the LICENSE file. -->
<!--  * Create on 2021-01-21 10:42:34 -->
<!--  * v1.9.01 -->
<!--  */ -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>assignclass</title>
	<link rel="stylesheet" type="text/css" href="../../css/je/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../css/je/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../../css/je/themes/color.css">
	<link rel="stylesheet" type="text/css" href="../../css/je/themes/demo.css">
	<script type="text/javascript" src="../../js/jquery.js"></script>
	<script type="text/javascript" src="../../js/jquery.easyui.min.js"></script>
<!--	<script type="text/javascript" src="../../js/jqeEx.js"></script>  -->
	<script type="text/javascript" src="../../js/js-ex2.js"></script>
	<script type="text/javascript" src="../../js/jquery.edatagrid.js"></script>
	<script type="text/javascript" src="../../js/suid-jq.js"></script>
<!--	<script type="text/javascript" src="../js/assignclass/assignclass.js"></script> -->
</head>
<body>
	<table id="dg" title="Data List" class="easyui-datagrid" style="width:950px;height:535px" idField="id"
			toolbar="#toolbar">
		<thead>
			<tr>
			    <th field="ck" checkbox="true"></th>
                 <th field="id"   hidden="true"  width="50" >ID</th>
                 <th field="schoolname"   width="80" >学校名称</th>
                 <th field="classno"   width="50"  editor="text">班级</th>
                 <th field="term"   width="50"  editor="text">学期</th>
                 <th field="stuno"   width="90"  editor="text">学号</th>
                 <th field="name"   width="70"  editor="text">姓名</th>
                 <th field="type"   width="60"  editor="text">固定排班</th>
                 <th field="creater"   width="50" >创建者</th>
                 <th field="updater"   width="50" >修改者</th>
                 <th field="remark"   width="50"  editor="text">备注</th>
                 <th field="status"   width="50" >status</th>
			</tr>
		</thead>
			
	</table>
	<div id="toolbar">
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add()">New</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="javascript:$('#dg').edatagrid('saveRow')">Save</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="javascript:$('#dg').edatagrid('cancelRow')">Cancel</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="del()">Delete</a>
	  
     <form name="formSearch" id="formSearch">
	    <span>班级:</span><input name="classno" style="line-height:26px;border:1px solid #ccc">
	    <span>学期:</span><input name="term" style="line-height:26px;border:1px solid #ccc">
	    <span>学号:</span><input name="stuno" style="line-height:26px;border:1px solid #ccc">
	    <span>姓名:</span><input name="name" style="line-height:26px;border:1px solid #ccc">
	    <span>固定排班:</span><input name="type" style="line-height:26px;border:1px solid #ccc">
	    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search"  plain="true" onclick="find()">Search</a>
     </form>
	 
	 </div>
	 
	<div id="dlg-new" class="easyui-dialog" style="width:800px;height:580px;" data-options="closed:true,modal:true,border:'thin',buttons:'#dlg-buttons-new'">
	 <div style="padding:20px 10px 40px 40px;">
		
		<form id="formNew" method="post" novalidate accept-charset="UTF-8">
			     <div style="margin-bottom:10px">
				    <input name="schoolname" class="easyui-textbox"  label="学校名称" style="width:95%">
			     </div> 
			     <div style="margin-bottom:10px">
				    <input name="classno" class="easyui-textbox" required="true" label="班级" style="width:95%">
			     </div> 
			     <div style="margin-bottom:10px">
				    <input name="term" class="easyui-textbox"  label="学期" style="width:95%">
			     </div> 
			     <div style="margin-bottom:10px">
				    <input name="stuno" class="easyui-textbox" required="true" label="学号" style="width:95%">
			     </div> 
			     <div style="margin-bottom:10px">
				    <input name="name" class="easyui-textbox"  label="姓名" style="width:95%">
			     </div> 
			     <div style="margin-bottom:10px">
				    <input name="type" class="easyui-textbox"  label="固定排班" style="width:95%">
			     </div> 
			     <div style="margin-bottom:10px">
				    <input name="creater" class="easyui-textbox"  label="创建者" style="width:95%">
			     </div> 
			     <div style="margin-bottom:10px">
				    <input name="updater" class="easyui-textbox"  label="修改者" style="width:95%">
			     </div> 
			     <div style="margin-bottom:10px">
				    <input name="remark" class="easyui-textbox"  label="备注" style="width:95%">
			     </div> 
			     <div style="margin-bottom:10px">
				    <input name="status" class="easyui-textbox"  label="status" style="width:95%">
			     </div> 
		</form>
		
	  </div>
	</div>
	<div id="dlg-buttons-new">
		<a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" plain="true" onclick="insert()" style="width:90px">Save</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="closeNew()" style="width:90px">Cancel</a>
  </div>
	
	<script type="text/javascript">
	
	/*
	 * Copyright 2016-2021 the original author.All rights reserved.
	 * AiTeasoft.com
	 * Kingstar(aiteasoft@163.com)
	 * The license,see the LICENSE file.
	 */
	 
	 $(function(){
			 $("#dg").edatagrid({
                 fit : true,
//				 fitColumns:"true",
				 height:'auto',
//               height:"535px",
//				 singleSelect:false,
//				 collapsible:true,
				 method:'get',
				 pagination:true,
				 rownumbers:true,
				 url: rootpath+'/assignclass/list',
				 
				 onLoadSuccess:function(result){
					if (result.errorMsg){
						$.messager.show({
							title: 'Error',
							msg: result.errorMsg
						});
					} else {
						  //...
					} 
				 } ,
		        
	             onLoadError:function(e){
			    	$.messager.show({
					title: '加载错误',
					msg: e.status+"  :  "+e.statusText
				   });
		        },
		        
		         onClickRow:function(rowIndex){
		        	 $(this).datagrid('clearSelections');
		        	 $(this).edatagrid('selectRow', rowIndex);
			     },
		        
		         onSave: function (index, row) {
		        	update(row);
		          }
			});
			 
			 turnPage("assignclass"); 
	 });  

	  function closeNew(){
			$('#dlg-new').dialog('close');
	  }
	 
		function add(){ //打开一个对话框
			$('#dlg-new').dialog('open').dialog('center').dialog('setTitle','New');
			$('#formNew').form('clear');
		}
		
		function insert(){
			if(!$("#formNew").form('validate')) return;
// 			var data = $("#formNew").serialize(); 
			var data = $("#formNew").serializeFilterNull();
			   $.ajax({ 
			    type:'post',  
			    url:rootpath+'/assignclass/add', 
			    data:data,  
			    dataType:'json', 
			    error:function(e){  
                    $.messager.show({
						title: 'Error',
						msg: e.status+"  :  "+e.statusText
					});
                }, 
			    
			   success: function(result){
				if (result.errorMsg){
					$.messager.show({
						title: 'Error',
						msg: result.errorMsg
					});
				} else {
					$.messager.show({
						title: 'Successfully',
						msg: 'Successfully!'
					});
					$('#dlg-new').dialog('close');
					$('#dg').datagrid('reload');
				}
			}
		});
		}
		function update(data){
			   $.ajax({ 
			    type:'post',  
			    url:rootpath+'/assignclass/edit', 
			    data:data,  
			    dataType:'json', 
			    
			    error:function(e){  
                    $.messager.show({
						title: 'Error',
						msg: e.status+"  :  "+e.statusText
					});
                }, 
			    success: function(result){
				if (result.errorMsg){
					$.messager.show({
						title: 'Error',
						msg: result.errorMsg
					});
				} else {
					$.messager.show({
						title: 'Successfully',
						msg: 'Successfully!'
					});
					 $("#dg").edatagrid("getPager").pagination('refresh', {
	                        pageNumber : 1               //fix easyui bug
	                    });
					 
					$('#dg').edatagrid('reload');
				}
			}
		});
		}
		
		function del(){
// 			var row = $('#dg').datagrid('getSelected');
			var row=$("#dg").datagrid("getSelections");
			if(row.length<=0) {
				alert("Please select one row first !");
				return ;
			}
			if (row){
				$.messager.confirm('Confirm','Are you sure delete the record(s)?',function(r){
					if (r){
						var ids;
						for(var i=0;i<row.length;i++){
							if(i==0){
								ids=(row[i].id);
							}else{
								ids+=","+row[i].id;
							}
						}
						
				         var data={};
						 data.ids=ids;
						
						  $.ajax({ 
							  type:'post',  
							  url: rootpath+'/assignclass/del',
							  data: data,  
							  dataType:'json', 
						      success:function(result){
							      if (result.errorMsg){
								    $.messager.show({	// show error message
									  title: 'Error',
									  msg: result.errorMsg
								    });
							    }else{
								    $('#dg').datagrid('reload');
								    $.messager.show({
									  title: 'delete',
									  msg: 'Delete successfully'
								    });	
							   }
						      },
					       error:function(e){  
		                    $.messager.show({
								title: 'Error',
								msg: e.status+"  :  "+e.statusText
							});
		                }
						  }
						); 
					}
				});
			}
		}
	
		function find(){
           var page=1;
           var pageSize=$("#dg").edatagrid("getPager").data("pagination").options.pageSize;
           
    	 /* var data={};
		    if($('#id').val()!=""){
			data.id=$('#id').val();
		   } */
 			var data = $("#formSearch").serializeFilterNull();
 			$.post(rootpath+'/assignclass/list?page='+page+'&rows='+pageSize,data,
			     function(result){
 				
			  	    if (result.errorMsg){
				    	$.messager.show({	// show error message
						  title: 'Error',
						  msg: result.errorMsg
					 });
				    }
 				
				      if (result){
	                    //将搜索结果显示在当前页面
	                    $("#dg").edatagrid("loadData", result.rows);
	                    $("#dg").edatagrid("getPager").pagination('refresh', {
	                        total: result.total
	                    });
	                }
			},'json'); 
		}
	</script>
	
</body>
</html>